<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>图像转文字</title>
    <script>
      function uploadFile() {
        const input = document.getElementById("fileInput");
        const file = input.files[0];
        const formData = new FormData();
        formData.append("file", file);

        fetch("/identify", {
          // 这里的 '/upload' 是处理文件上传的服务器端API路径
          method: "POST",
          body: formData,
        })
          .then((response) => response.json())
          .then((data) => {
            console.log(data);
          })
          .catch((error) => {
            console.error(error);
          });
      }
    </script>
  </head>
  <body>
    <h2>图像转文字</h2>
    <input type="file" id="fileInput" />
    <button onclick="uploadFile()">上传文件</button>
  </body>
</html>
